<?php
/* 
 * ********* CVS HEADER ********* 
 * 
 * $RCSfile: admenvliste.php,v $ 
 * $Date: 2006/03/16 20:21:21 $ 
 * $Revision: 1.3 $ 
 * 
 * ********* CVS HEADER ********* 
 */
global $rportalconstants;
$L_base_env = get_env_path();
require_once("module/TPLN/TPLN.php");
$TPLN = new TPLN;
$TPLN->Open($op_basepath.get_path("tpl")."admenvliste.html");
$TPLN->IncludeFile("header",$L_base_env.$session['environnement']."/header.php");
$query = "SELECT *,IF(lastmod <= lastgen ,'vert','rouge') AS statut";
$query.= " FROM environnement ORDER BY nom";
$result=rportalrequete($query) or rportalerreur($query,"?op=admenvliste");
$class[0]="liste_impaire";
$class[1]="liste_paire";
$L_class = 0;
$L_bloc = "bloc1";
while($row=rportalligne($result))
{
	$TPLN->Parse($L_bloc.".couleur",$row['statut']);
    $TPLN->Parse($L_bloc.".classe",$class[$L_class]);
    $TPLN->Parse($L_bloc.".nom",$row['nom']);
    $TPLN->Parse($L_bloc.".description",$row['description']);
    $TPLN->Parse($L_bloc.".accueil",$row['accueil']);
    $TPLN->Parse($L_bloc.".id",$row['id']);
    $L_class = 1 - $L_class;
	$TPLN->Loop($L_bloc);
}

$L_subBloc = "blocInstaller";
$L_bloc = $L_subBloc . ".bloc2";
$L_environnement = "environnement.html";
$L_class = 0;
$dir=dir($L_base_env);
$L_effacer = true;
$L_select = "checked";
while ($fichier = $dir->read()) {
	$L_filename = $L_base_env.$fichier;
	$L_env_filename  = $rportalconstants->get_value("RPORTAL", "environnement.filename.prefix");
	$L_env_filename .= "." . $fichier;
	$L_env_filename .= $rportalconstants->get_value("RPORTAL", "environnement.filename.extension");
	if (is_dir($L_filename)) {
		switch ($fichier) {
			case ".":
			case "..":
				continue(2);
			default:
				break;
		}
		if (!file_exists($L_filename."/".$L_environnement)) {
			/* Pas d'environnement deja cree */
			if (file_exists($L_filename."/".$L_env_filename)) {
				/* fichier de sauvegarde present */
				
				$L_effacer = false;
			    $TPLN->Parse($L_bloc.".classe",$class[$L_class]);
			    $L_class = 1 - $L_class;
			    $TPLN->Parse($L_bloc.".selectionner",$L_select);
			    $TPLN->Parse($L_bloc.".nom",$fichier);
				$TPLN->Loop($L_bloc);
				$L_select = "";
			}
		}
	}
}
if ($L_effacer) {
	$TPLN->EraseBloc($L_subBloc);
} else {
	$TPLN->Parse($L_subBloc.".generer","generer");
	$TPLN->Loop($L_subBloc);
}

require_once(get_path_module("admin")); 
$pc = new panneau_controle(); 
$pc->calculRubriqueParFonction($op); 
$TPLN->Parse("panneau_controle",$pc->retourneEntete());

$TPLN->IncludeFile("footer",$L_base_env.$session['environnement']."/footer.php");
$TPLN->Write();
?>